package com.lzm.easyexcel.controller;

import com.lzm.easyexcel.dto.TestExportDto;
import com.lzm.easyexcel.utils.EasyExcelUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author liuzemin
 * @date 2023/8/21 0021 10:37
 * @description
 */
@RestController
@Slf4j
public class TestController {

    @PostMapping("/exportTest")
    public void exportTest(HttpServletResponse response) throws IOException {
        List<TestExportDto> data = new ArrayList<>();
        data.add(new TestExportDto("小明", "小名"));

        EasyExcelUtil.write("test", "test", TestExportDto.class, data, response);
        log.info("导出测试");
    }
}
